/* This is a generated file. Don't edit. Edit the source instead.
 */

#include <stdlib.h>
#include "cmd_table.h"
#include "sphashd_client.h"

static int hs_cmd_add_hash(void *user_data, int argc, char **argv)
{
    hs_t *hs = user_data;
    if(hs == NULL) return 0;
    if(argc != 4) return 0;
    char *filename = argv[0];
    char *hash_base32 = argv[1];
    char *leaves_base64 = argv[2];
    double mibs_per_sec = strtod(argv[3], NULL);
    if(hs->cb_add_hash)
        return hs->cb_add_hash(hs, filename, hash_base32, leaves_base64, mibs_per_sec);
    return 0;
}

static int hs_cmd_fail_hash(void *user_data, int argc, char **argv)
{
    hs_t *hs = user_data;
    if(hs == NULL) return 0;
    if(argc != 1) return 0;
    char *filename = argv[0];
    if(hs->cb_fail_hash)
        return hs->cb_fail_hash(hs, filename);
    return 0;
}
static cmd_t hs_cmds[] = {
    {"add-hash", hs_cmd_add_hash, 4},
    {"fail-hash", hs_cmd_fail_hash, 1},
    {0, 0, -1}
};

hs_t *hs_init(void)
{
    hs_t *hs = calloc(1, sizeof(hs_t));
    return hs;
}

int hs_dispatch_command(const char *line, const char *delimiters,
        int allow_null_elements, hs_t *hs)
{
    return cmd_dispatch(line, delimiters, allow_null_elements,
        hs_cmds, hs);
}
